/**
 * @author SaoE
 * @date 2025/3/7 21:03
 */
public class _560 {
    public int subarraySum(int[] nums, int k) {
        int sum = 0;
        int start = 0;
        int res = 0;
        for(int i = start; i < nums.length; i++){
            sum += nums[i];
            if(sum == k) {
                sum -= nums[start];
                start++;
                res++;
                i = start;
            }
        }
        return res;
    }
}
